"""
@Author  : 康帅
@Time    : 2021/3/18 9:14
@Function: 代理模式：代取快递案例
"""

from abc import ABCMeta, abstractmethod


class ReceiveParcel(metaclass=ABCMeta):
    """ 接收包裹抽象 """

    def __init__(self, name):
        self.__name = name

    def get_name(self):
        return self.__name

    @abstractmethod
    def receive(self, parcel_content):
        pass


class TonyReception(ReceiveParcel):
    """ Tony接收 """

    def __init__(self, name, phone_num):
        super().__init__(name)
        self.__phone_num = phone_num

    def get_phone_num(self):
        return self.__phone_num

    def receive(self, parcel_content):
        print("货物主人：%s,手机号：%s" % (self.get_name(), self.get_phone_num()))
        print("接收到一个包裹，包裹内容：%s" % parcel_content)


class WendyReception(ReceiveParcel):
    """ Wendy代收 """

    def __init__(self, name, receiver):
        super().__init__(name)
        self.__receiver = receiver

    def receive(self, parcel_content):
        print("我是%s的朋友，我来帮他取快递！" % (self.__receiver.get_name() + ""))
        if self.__receiver is not None:
            self.__receiver.receive(parcel_content)
        print("代收人：%s" % self.get_name())


if __name__ == '__main__':
    tony = TonyReception("Tony", 13166668888)
    print("Tony接收：")
    tony.receive("雪地靴")
    print()

    print("Wendy代收：")
    wendy = WendyReception("Wendy", tony)
    wendy.receive("雪地靴")
